﻿Imports System.Data.OracleClient

Public Class TaskForm

    Dim ada As OracleDataAdapter
    Dim con As OracleConnection
    Dim bin As BindingSource
    Dim tab As DataTable
    Dim com As OracleCommand

    Private Sub TaskForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.conectar()
        Me.configurarAdaptador()
        Me.cargarGrilla()
        Me.desconectar()
    End Sub
    ' jfabro. 29/09/2011. Mover metodo a DataAccesConnection
    Private Sub conectar()
        con = New OracleConnection(DataAccessConnection.oracleConnectionString)
        con.Open()
    End Sub

    ' jfabro. 29/09/2011. Mover metodo a DataAccesConnection
    Private Sub desconectar()
        con.Close()
    End Sub

    Private Sub configurarAdaptador()
        ada = New OracleDataAdapter("select * from tipos_tarea", con)
    End Sub

    Private Sub cargarGrilla()
        com = New OracleCommand
        com.Connection = con
        com.CommandType = CommandType.Text
        com.CommandText = "SELECT * from tipos_tarea "
        'com.Parameters.Add(New OracleParameter("id", 1))

        ada.SelectCommand = com

        com = New OracleCommand
        com.Connection = con
        com.CommandType = CommandType.Text
        com.CommandText = "delete from tipos_tarea where id = :id"
        com.Parameters.Add(New OracleParameter("id", dgvTiposTarea.ite
        ada.DeleteCommand = com



        tab = New DataTable
        ada.Fill(tab)
        dgvTiposTarea.DataSource = tab
        bin = New BindingSource
        bin.DataSource = tab
        bnTiposTarea.BindingSource = bin

        'tab = New DataTable
        'ada.Fill(tab)
        'dgv.DataSource = tab
        'bin = New BindingSource
        'bin.DataSource = tab
        'bnPersonas.BindingSource = bin



    End Sub

    Private Sub BindingNavigatorCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorCancelar.Click
        bin.CancelEdit()
        MsgBox("Cancelar")
    End Sub

    Private Sub dgvTiposTarea_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvTiposTarea.CellContentClick
        MsgBox(dgvTiposTarea.CurrentCell.Value)
    End Sub

    Private Sub GuardarToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuardarToolStripButton.Click
        ada.Update(tab)
    End Sub
End Class